<?php

namespace app\api\controller;

use app\api\model\User as UserModel;
use app\Request;
use think\helper\Arr;

class Users
{
    public function index(Request $request)
    {
        $params = $request->param();
        $userModel = new UserModel();
        $users = $userModel->getAll($params);
        return show($users);
    }

    public function show(Request $request) {
        $id = $request->param('id');
        $userModel = new UserModel();
        $user = $userModel->getOne($id);
        Arr::add($user, 'count', $user->records()->count());
        return show($user);
    }
}